<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="/css/main.css"/>
  <link rel="stylesheet" href="/cms/layui/css/layui.css">
  <script src="/js/uikit.js"></script>
</head>

<body>
<div th:insert="~{common::#header}"></div>

<div class="uk-section uk-section-muted">
  <div class="uk-container">
    <div class="uk-background-default uk-border-rounded uk-box-shadow-small">
      <div class="uk-container uk-container-xsmall uk-padding-large">
        <article class="uk-article">
          <h1 class="uk-article-title">给我们留言</h1>
          <div class="uk-article-content">
            <p class="uk-text-lead uk-text-muted">您可以在线给我们留言，我们会在第一时间内对您的问题作出反馈。</p>
            <form class="uk-form-stacked uk-margin-medium-top" onsubmit="return false">

              <div class="uk-margin-bottom">
                <label class="uk-form-label" for="message">内容</label>
                <div class="uk-form-controls">
                  <textarea id="message" class="uk-textarea uk-border-rounded" name="message"></textarea>
                </div>
              </div>
              <div class="uk-text-center">
                <input class="uk-button uk-button-primary uk-border-rounded" onclick="submitContact()" type="submit"
                       value="提交留言">
              </div>
            </form>
          </div>
        </article>
      </div>
    </div>
  </div>
</div>

<div th:insert="~{common::#footer}"></div>

<script src="/js/awesomplete.js"></script>
<script src="/js/custom.js"></script>
<script src="/js/jquery.min.js"></script>
<script src="/cms/layui/layui.js" charset="utf-8"></script>

<script>
  function submitContact() {
    var message = $("#message").val();
    if (!message) {
      alert("请输入留言内容！");
      return false;
    }
    $.ajax({
      url: '/contact/add',
      type: 'POST',
      dataType: 'JSON',
      data: {
        contact: message
      },
      success: function (result) {
        if (result.code == 200) {
          alert(result.msg);
          window.location.reload();
        } else {
          alert(result.msg)
          return false;
        }
      }
    })
  }
</script>
</body>

</html>